const haveIntersection = (arr1: string[], arr2: string[]): boolean => {
  const set1 = new Set(arr1);
  return arr2.some((item) => set1.has(item));
};

export default haveIntersection;

export const hasPermission = (permissions: string[], metaPermission: string[]) => {
  if (!metaPermission?.length) return true;
  if (!haveIntersection(permissions, permissions as string[])) return false;
  return true;
};
